﻿using System;
using System.Windows.Browser;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.ServiceModel.Description;


namespace DXTools.Core.CrmSdk
{
    [DataContract(Namespace = "http://schemas.microsoft.com/crm/2011/Contracts")]
    public sealed class ImportSolutionRequest : OrganizationRequest
    {
        // Methods
        public ImportSolutionRequest()
        {
            base.RequestName = "ImportSolution";
            base.Parameters = new ParameterCollection();
            this.OverwriteUnmanagedCustomizations = false;
            this.PublishWorkflows = false;
            this.CustomizationFile = null;
            this.ImportJobId = new Guid();
        }

        // Properties
        public bool ConvertToManaged
        {
            get
            {
                return (base.Parameters.Contains("ConvertToManaged") && ((bool)base.Parameters["ConvertToManaged"]));
            }
            set
            {
                base.Parameters["ConvertToManaged"] = value;
            }
        }

        //[System.Xml.Serialization.XmlArrayItemAttribute(DataType = "base64Binary")]
        //[System.Xml.Serialization.XmlAttribute (DataType = "base64Binary")]
        public base64Binary CustomizationFile
        {
            get
            {
                if (base.Parameters.Contains("CustomizationFile"))
                {
                    return (base64Binary)base.Parameters["CustomizationFile"];
                }
                return null;
            }
            set
            {
                base.Parameters["CustomizationFile"] = value;
            }
        }

        public Guid ImportJobId
        {
            get
            {
                if (base.Parameters.Contains("ImportJobId"))
                {
                    return (Guid)base.Parameters["ImportJobId"];
                }
                return new Guid();
            }
            set
            {
                base.Parameters["ImportJobId"] = value;
            }
        }

        public bool OverwriteUnmanagedCustomizations
        {
            get
            {
                return (base.Parameters.Contains("OverwriteUnmanagedCustomizations") && ((bool)base.Parameters["OverwriteUnmanagedCustomizations"]));
            }
            set
            {
                base.Parameters["OverwriteUnmanagedCustomizations"] = value;
            }
        }

        public bool PublishWorkflows
        {
            get
            {
                return (base.Parameters.Contains("PublishWorkflows") && ((bool)base.Parameters["PublishWorkflows"]));
            }
            set
            {
                base.Parameters["PublishWorkflows"] = value;
            }
        }
    }

    partial class ParameterCollection
    {
        public bool Contains(string key)
        {
            return (this.Items.GetItem(key) != null);
        }

        public object this[string key]
        {
            get
            {
               return this.Items.GetItem(key);
            }
            set
            {
                this.Items.SetItem(key, value);
            }
        }
    }
}
